'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 邮件
 * @author sundbcn@gmail.com (sun debing)
 */

var moment = require('moment');
var mongoose = require('mongoose');
var _ = require('lodash');
var constantUtil = require('../../util/constantUtil');

///////////////////////////////////////////////////////////
/**
 * 邮件
 */
var friendItemSchema = new mongoose.Schema({
    // 角色id
    role_id: {
        type: Number,
        required: true
    },

    // 赠送体力状态
    is_send_energy: {
        type: Boolean,
        default: false
    },

    // 当前是否有可领取体力
    is_present_energy: {
        type: Boolean,
        default: false
    },

    // 当前是否有已经领取体力
    is_received_energy: {
        type: Boolean,
        default: false
    },

    // 是否点赞
    is_send_praise: {
        type: Boolean,
        default: false
    },

    // 当前是否有可领取点赞
    is_present_praise: {
        type: Boolean,
        default: false
    },

    // 好友点赞状态
    is_today_praise: {
        type: Boolean,
        default: false
    }
});

if (!friendItemSchema.options.toJSON) {
    friendItemSchema.options.toJSON = {};
}

/* jshint unused:false */
friendItemSchema.options.toJSON.transform = function (doc, ret) {
    if (ret.is_send_energy !== undefined) {
        ret.is_send_energy = +ret.is_send_energy;
    }

    if (ret.is_present_energy !== undefined) {
        ret.is_present_energy = +ret.is_present_energy;
    }

    if (ret.is_received_energy !== undefined) {
        ret.is_received_energy = +ret.is_received_energy;
    }

    if (ret.is_send_praise !== undefined) {
        ret.is_send_praise = +ret.is_send_praise;
    }

    if (ret.is_present_praise !== undefined) {
        ret.is_present_praise = +ret.is_present_praise;
    }

    if (ret.is_today_praise !== undefined) {
        ret.is_today_praise = +ret.is_today_praise;
    }
    delete ret._id;
    delete ret.__v;
};

module.exports = friendItemSchema;
